home *** CD-ROM | disk | FTP | other *** search
/ Family Forum 261 / SOMC Family Forum 261.iso / Xtras / Animation Wizard.dir / 00005_Script_IncrDecrCast < prev    next >
Text File  |  1997-05-10  |  2KB  |  93 lines

  1. -- IncrDecrCast script
  2.  
  3. property iCastNumOffset
  4. property inPicts
  5. property ichPict
  6. property ichButton
  7. property iCurrentValue
  8. property iCastNumNormal
  9. property iCastNumIncr
  10. property iCastNumDecr
  11.  
  12. on birth me
  13.   return me
  14. end birth
  15.  
  16. on mInit me, castNumOffset, defaultVal, nPicts, chPict 
  17.   set iCastNumOffset = castNumOffset
  18.   set inPicts = nPicts
  19.   set ichPict = chPict
  20.   set ichButton = ichPict + 1
  21.   mSetValue(me, defaultVal)
  22.   puppetsprite ichPict, TRUE
  23. end mInit
  24.  
  25. on mHit me
  26.   set castNumNormal = the castnum of sprite ichButton
  27.   set iCastNumNormal = castNumNormal
  28.   set iCastNumIncr = castNumNormal + 1
  29.   set iCastNumDecr = castNumNormal + 2
  30.   
  31.   
  32.   set mouseDownFlag = TRUE
  33.   set firstTimeFlag = TRUE
  34.   repeat while mouseDownFlag
  35.     if rollOver(ichButton) then
  36.       
  37.       if the mouseV <= the locV of sprite ichButton then  -- upper half, increase
  38.         set the castNum of sprite ichButton = iCastNumIncr 
  39.         set iCurrentValue = IncrMod(iCurrentValue, inPicts)
  40.         
  41.       else -- lower half, decrement
  42.         set the castNum of sprite ichButton = iCastNumDecr 
  43.         set iCurrentValue = DecrMod(iCurrentValue, inPicts)
  44.         
  45.       end if
  46.       mDraw(me)
  47.       
  48.     else  -- not currently rolled over the button
  49.       set the castNum of sprite ichButton = castNumNormal
  50.       updateStage
  51.     end if 
  52.     
  53.     if firstTimeFlag then  -- this allows for easy one step increments
  54.       set firstTimeFlag = FALSE
  55.       wait(15)
  56.     end if    
  57.     set mouseDownFlag = the mouseDown
  58.     
  59.   end repeat  
  60.   set the castNum of sprite ichButton = castNumNormal
  61.   updateStage
  62.   return iCurrentValue
  63. end mHit
  64.  
  65.  
  66. on mGetValue me
  67.   return iCurrentValue
  68. end mGetValue
  69.  
  70. on mGetCastNum me, index
  71.   return (iCastNumOffset + index)
  72. end mGetCastNum
  73.  
  74.  
  75. on mSetValue me, theNewValue
  76.   if (theNewValue < 1) or (theNewValue > inPicts) then
  77.     alert("Bad value passed to IncrDecrCast:"  && theNewValue & RETURN¼
  78.           & "Needs to be between 1 and " & inPicts)
  79.     return
  80.   end if
  81.   set iCurrentValue = theNewValue
  82.   mDraw(me)
  83.   updateStage
  84. end mSetValue
  85.  
  86. on mDraw me  
  87.   set the castNum of sprite ichPict = iCastNumOffset + iCurrentValue
  88.   updateStage
  89. end mDraw
  90.  
  91. on mCleanup me  
  92.   puppetsprite ichPict, FALSE
  93. end mCleanup